package com.hyphenate.easeui.widget.chatrow;

import android.content.Context;
import android.graphics.Bitmap;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hyphenate.chat.EMMessage;
import com.hyphenate.easeui.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;

/**
 * big emoji icons
 *
 */
public class EaseChatRowBigExpression extends EaseChatRowText{

    private ImageView imageView;


    public EaseChatRowBigExpression(Context context, EMMessage message, int position, BaseAdapter adapter) {
        super(context, message, position, adapter);
    }
    
    @Override
    protected void onInflatView() {
        inflater.inflate(message.direct() == EMMessage.Direct.RECEIVE ? 
                R.layout.ease_row_received_bigexpression : R.layout.ease_row_sent_bigexpression, this);
    }

    @Override
    protected void onFindViewById() {
        percentageView = (TextView) findViewById(R.id.percentage);
        imageView = (ImageView) findViewById(R.id.image);
    }


    @Override
    public void onSetUpView() {
//        String emojiconId = message.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null);
//        EaseEmojicon emojicon = null;
//        if(EaseUI.getInstance().getEmojiconInfoProvider() != null){
//            emojicon =  EaseUI.getInstance().getEmojiconInfoProvider().getEmojiconInfo(emojiconId);
//        }
//        if(emojicon != null){
//            if(emojicon.getBigIcon() != 0){
//               // Glide.with(activity).load(emojicon.getBigIcon()).placeholder(R.drawable.ease_default_expression).into(imageView);
//               // com.nostra13.universalimageloader.core.ImageLoader.getInstance().displayImage(emojicon.getBigIcon(), imageView, options);
//
//            }else if(emojicon.getBigIconPath() != null){
//               // Glide.with(activity).load(emojicon.getBigIconPath()).placeholder(R.drawable.ease_default_expression).into(imageView);
//                com.nostra13.universalimageloader.core.ImageLoader.getInstance().displayImage(emojicon.getBigIconPath(), imageView, options);
//            }else{
//                imageView.setImageResource(R.drawable.ease_default_expression);
//            }
//        }
        imageView.setImageResource(R.drawable.ease_default_expression);
        handleTextMessage();
    }
    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .showImageOnLoading(R.drawable.ease_default_expression)
            .showImageOnFail(R.drawable.ease_default_expression)
            .showStubImage(R.drawable.ease_default_expression)
            .imageScaleType(ImageScaleType.EXACTLY)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();
}
